package com.fast.alden.admin.service.impl;

import com.fast.alden.admin.service.SysApiResourceCacheService;
import com.fast.alden.common.service.RedisService;
import com.fast.alden.data.model.SysApiResource;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysApiResourceCacheServiceImpl implements SysApiResourceCacheService {
    @Resource
    private RedisService redisService;
    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public List<SysApiResource> list() {
        return (List<SysApiResource>) redisService.get(CACHE_KEY_SYS_API_RESOURCE_LIST);
    }

    @Override
    public void setList(List<SysApiResource> list) {
        redisService.set(CACHE_KEY_SYS_API_RESOURCE_LIST, list);
    }

    @Override
    public void flushApiResourceList() {
        redisService.del(CACHE_KEY_SYS_API_RESOURCE_LIST);
    }
}
